package com.q.course.entity.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * 统一定义id的entity基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * 子类可重载getId()函数重定义id的列名映射和生成策略.
 * 
 */
//JPA 基类的标识
@MappedSuperclass
public abstract class BaseEntity {

	/** 主键 */
	protected Long id;
	/** 创建时间 */
	private Date addTime = new Date();
	/** 存在状态 */
	private Boolean existState = true;

	@Id
	@GeneratedValue( strategy = GenerationType.IDENTITY )
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Column( name = "add_time" , nullable = true )
	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column( name = "exist_state" )
	public Boolean getExistState() {
		return existState;
	}

	public void setExistState(Boolean existState) {
		this.existState = existState;
	}

}
